﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Properties;
using System.Data;
using System.Data.SqlClient;

namespace IngressApp.DAC
{
    public class DACRead
    {
        DBInfo Info = new DBInfo();
        DataTable table = new DataTable();
        
        public DataTable readEmpleados()
        {

            SqlConnection con = new SqlConnection(Info.sqlSet());
            string query = "SELECT * FROM Empleado";
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            SqlDataAdapter DA = new SqlDataAdapter(com);

            DA.Fill(table);
            return table;
        }
        public DataTable readEmpleadosHuellas()
        {

            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_EmpleadoHuella_SelectAll", con);
            cmd.CommandType = CommandType.StoredProcedure;

            //cmd.Parameters.Add("@IdEmpleadoHuella", SqlDbType.VarChar).Value = 13;




            con.Open();

            SqlDataAdapter DA = new SqlDataAdapter(cmd);

            DA.Fill(table);
            return table;
        }
        
        public DataTable readEmpleadoHuella()
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_EmpleadoHuella_SelectRow", con);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@IdEmpleadoHuella", SqlDbType.VarChar).Value = 13;

        
            
            
            con.Open();

            SqlDataAdapter DA = new SqlDataAdapter(cmd);

            DA.Fill(table);
            return table;
        }

        public DataTable readRegistros()
        {

            SqlConnection con = new SqlConnection(Info.sqlSet());
            string query = "SELECT * FROM Registro";
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            SqlDataAdapter DA = new SqlDataAdapter(com);

            DA.Fill(table);
            return table;
        }
        public DataTable readTiposHuellas()
        {

            SqlConnection con = new SqlConnection(Info.sqlSet());
            string query = "SELECT * FROM TipoHuella";
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            SqlDataAdapter DA = new SqlDataAdapter(com);

            DA.Fill(table);
            return table;
        }
        public DataTable readEmpleado(int idEmpleado)
        {

            SqlConnection con = new SqlConnection(Info.sqlSet());
            string query = "SELECT * FROM Empleado WHERE IdEmpleado = "+idEmpleado+"";
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            SqlDataAdapter DA = new SqlDataAdapter(com);

            DA.Fill(table);
            return table;
        }
        public DataTable readEmpleadoUltimo()
        {

            SqlConnection con = new SqlConnection(Info.sqlSet());
            string query = "select IDENT_CURRENT('Empleado')";
            SqlCommand com = new SqlCommand(query, con);
            con.Open();

            SqlDataAdapter DA = new SqlDataAdapter(com);

            DA.Fill(table);
            return table;
        }
        
    }
}
